﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGePoint2d : IDisposable
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGePoint2d(IntPtr cPtr, bool cMemoryOwn)
		{
			this.swigCMemOwn = cMemoryOwn;
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGePoint2d obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGePoint2d()
		{
			this.Dispose();
		}

		public virtual void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGePoint2d(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
		}

		public static OdGePoint2d operator +(OdGePoint2d p, OdGeVector2d v)
		{
			return p.Add(v);
		}

		public static OdGePoint2d operator -(OdGePoint2d p, OdGeVector2d v)
		{
			return p.Sub(v);
		}

		public static OdGePoint2d operator *(OdGePoint2d v, double d)
		{
			return v.Mul(d);
		}

		public override string ToString()
		{
			if (this.swigCPtr.Handle == IntPtr.Zero)
			{
				return "Empty";
			}
			return string.Format("({0}, {1})", this.x, this.y);
		}

		public OdGePoint2d() : this(GlobalsPINVOKE.new_OdGePoint2d__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint2d(OdGePoint2d source) : this(GlobalsPINVOKE.new_OdGePoint2d__SWIG_1(OdGePoint2d.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGePoint2d(double xx, double yy) : this(GlobalsPINVOKE.new_OdGePoint2d__SWIG_2(xx, yy), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public static OdGePoint2d kOrigin
		{
			get
			{
				IntPtr intPtr = GlobalsPINVOKE.OdGePoint2d_kOrigin_get();
				OdGePoint2d result = (intPtr == IntPtr.Zero) ? null : new OdGePoint2d(intPtr, false);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
		}

		public OdGePoint2d setToProduct(OdGeMatrix2d matrix, OdGePoint2d point)
		{
			GlobalsPINVOKE.OdGePoint2d_setToProduct(this.swigCPtr, OdGeMatrix2d.getCPtr(matrix), OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGePoint2d transformBy(OdGeMatrix2d xfm)
		{
			GlobalsPINVOKE.OdGePoint2d_transformBy(this.swigCPtr, OdGeMatrix2d.getCPtr(xfm));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGePoint2d rotateBy(double angle, OdGePoint2d basePoint)
		{
			GlobalsPINVOKE.OdGePoint2d_rotateBy__SWIG_0(this.swigCPtr, angle, OdGePoint2d.getCPtr(basePoint));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGePoint2d rotateBy(double angle)
		{
			GlobalsPINVOKE.OdGePoint2d_rotateBy__SWIG_1(this.swigCPtr, angle);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGePoint2d mirror(OdGeLine2d line)
		{
			GlobalsPINVOKE.OdGePoint2d_mirror(this.swigCPtr, OdGeLine2d.getCPtr(line));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGePoint2d scaleBy(double scaleFactor, OdGePoint2d basePoint)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_scaleBy__SWIG_0(this.swigCPtr, scaleFactor, OdGePoint2d.getCPtr(basePoint)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d scaleBy(double scaleFactor)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_scaleBy__SWIG_1(this.swigCPtr, scaleFactor), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d Mul(double scale)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_Mul__SWIG_0(this.swigCPtr, scale), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d Div(double scale)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_Div__SWIG_0(this.swigCPtr, scale), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d Add(OdGeVector2d vect)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_Add__SWIG_0(this.swigCPtr, OdGeVector2d.getCPtr(vect)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d Sub(OdGeVector2d vect)
		{
			OdGePoint2d result = new OdGePoint2d(GlobalsPINVOKE.OdGePoint2d_Sub__SWIG_0(this.swigCPtr, OdGeVector2d.getCPtr(vect)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d setToSum(OdGePoint2d point, OdGeVector2d vect)
		{
			GlobalsPINVOKE.OdGePoint2d_setToSum(this.swigCPtr, OdGePoint2d.getCPtr(point), OdGeVector2d.getCPtr(vect));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public OdGeVector2d Sub(OdGePoint2d point)
		{
			OdGeVector2d result = new OdGeVector2d(GlobalsPINVOKE.OdGePoint2d_Sub__SWIG_2(this.swigCPtr, OdGePoint2d.getCPtr(point)), true);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeVector2d asVector()
		{
			OdGeVector2d result = new OdGeVector2d(GlobalsPINVOKE.OdGePoint2d_asVector(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double distanceTo(OdGePoint2d point)
		{
			double result = GlobalsPINVOKE.OdGePoint2d_distanceTo(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsEqual(OdGePoint2d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint2d_IsEqual(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool IsNotEqual(OdGePoint2d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint2d_IsNotEqual(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEqualTo(OdGePoint2d point, OdGeTol tol)
		{
			bool result = GlobalsPINVOKE.OdGePoint2d_isEqualTo__SWIG_0(this.swigCPtr, OdGePoint2d.getCPtr(point), OdGeTol.getCPtr(tol));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEqualTo(OdGePoint2d point)
		{
			bool result = GlobalsPINVOKE.OdGePoint2d_isEqualTo__SWIG_1(this.swigCPtr, OdGePoint2d.getCPtr(point));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public double GetItem(uint i)
		{
			double result = GlobalsPINVOKE.OdGePoint2d_GetItem(this.swigCPtr, i);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGePoint2d set(double xx, double yy)
		{
			GlobalsPINVOKE.OdGePoint2d_set(this.swigCPtr, xx, yy);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return new OdGePoint2d(this);
		}

		public double x
		{
			get
			{
				double result = GlobalsPINVOKE.OdGePoint2d_x_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGePoint2d_x_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		public double y
		{
			get
			{
				double result = GlobalsPINVOKE.OdGePoint2d_y_get(this.swigCPtr);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
				return result;
			}
			set
			{
				GlobalsPINVOKE.OdGePoint2d_y_set(this.swigCPtr, value);
				if (GlobalsPINVOKE.SWIGPendingException.Pending)
				{
					throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
				}
			}
		}

		private object locker = new object();

		private HandleRef swigCPtr;

		protected bool swigCMemOwn;
	}
}
